// Humming Owl's Multipurpose Library

#ifndef homl_h
#define homl_h

// HOML header includes
#include "basic_types.h"
#include "mem_space.h"
#include "endian.h"
#include "other_types/byte_arr.h"

// useful definitions for a kind of "typeof" function (might be a dumb addition)
// using the enums chained between headers (first one is in basic_types.h)

// typeof
owl_char * OWL_TYPE_NAMES[] =
{
  "OWL_BYTE",
  "OWL_CHAR",
  "OWL_UMAX",
  "OWL_SMAX",
  "OWL_FMAX",
  "OWL_BOOL",
  "OWL_MEM_SPACE",
  "OWL_MEM_SPACE_ERR",
  "OWL_ENDIAN",
  "OWL_BYTESHIFT_DIR",
  "OWL_BYTARR",
  "OWL_ARR",
  "OWL_WCHAR_ENC",
  "OWL_WCHAR",
  "OWL_STR",
};

// sizeof
owl_umax OWL_TYPE_SIZES[] =
{
  sizeof(owl_byte),
  sizeof(owl_char),
  sizeof(owl_umax),
  sizeof(owl_smax),
  sizeof(owl_fmax),
  sizeof(owl_bool),
  sizeof(owl_endian),
  sizeof(owl_mem_space),
  sizeof(owl_mem_space_err),
  sizeof(owl_byteshift_dir),
  sizeof(owl_bytarr),
  sizeof(owl_arr),
  sizeof(owl_wchar_enc),
  sizeof(owl_wchar),
  sizeof(owl_str),
};

// function to return the type string of a type integer
owl_char * owl_type_name(owl_umax type_id)
{
  // check params
  if (type_id > sizeof(OWL_TYPE_NAMES) - 1)
    return NULL;
  return OWL_TYPE_NAMES[type_id];
}

// function to return the type size of a type integer
owl_umax owl_type_size(owl_umax type_id)
{
  // check params
  if (type_id > sizeof(OWL_TYPE_NAMES) - 1)
    return 0;
  return OWL_TYPE_SIZES[type_id];
}

#endif // homl_h
